package org.gvp.generator.props;

import lombok.Getter;

@Getter
public class DatabaseProps {

    private String port = "3306";
    private String host = "localhost";
    private String dbName;
    private String username = "root";
    private String password = "123456";
    /**
     * 使用builder构建
     */
    private String url ;
    private String driver = "com.mysql.cj.jdbc.Driver" ;

    private DatabaseProps() {
    }
    public static DatabaseProps build(){
        return new DatabaseProps();
    }

    public DatabaseProps port(String port){
        this.port = port;
        return this;
    }
    public DatabaseProps host(String host){
        this.host = host;
        return this;
    }
    public DatabaseProps dbName(String dbName){
        this.dbName = dbName;
        return this;
    }
    public DatabaseProps username(String username){
        this.username = username;
        return this;
    }
    public DatabaseProps password(String password){
        this.password = password;
        return this;
    }

    public DatabaseProps builder(){
        this.url = "jdbc:mysql://%s:%s/%s?serverZoneId=Asia/Shanghai"
                .formatted(this.host,this.port,this.dbName);
        return this;
    }
}
